<?php

namespace app\admin\model;

use app\admin\model\service\Agent;
use app\common\model\GoodsModel;
use think\Model;
use app\admin\controller\product\Category as ProductCategory;
use app\admin\controller\env\Category as EnvCategory;

class Order extends Model
{





    // 表名
    protected $name = 'order';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [

    ];



    public function productCategory(){
        return $this->belongsToMany(
            ProductCategory::class,
            "order_product_category_relation",
            "product_category_id",
            "order_id"
        );
    }
    public function envCategory(){
        return $this->belongsToMany(
            EnvCategory::class,
            "order_env_category_relation",
            "env_category_id",
            "order_id"
        );
    }

    public  function  company(){
        return $this->hasOne(Company::class,'id','company_id');
    }
    public  function  agent(){
        return $this->hasOne(Agent::class,'id','service_agent_id');
    }

    public  function  report(){
       return $this->belongsTo(Report::class,'id','order_id');
    }
    public  function  certificate(){
       return $this->belongsTo(Certificate::class,'id','order_id');
    }


    public  function  goods(){
        return $this->hasOne(GoodsModel::class,'id','goods_id');

    }







}
